package com.smartwebx.ha.web.admin.module.screen.report;

import java.io.IOException;

import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.citrus.turbine.dataresolver.Param;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.smartwebx.ha.biz.assign.HaDirectoryManager;
import com.smartwebx.ha.biz.assign.HaReportAreaManager;
import com.smartwebx.ha.biz.assign.HaReportManager;
import com.smartwebx.ha.biz.assign.HaReportUserManager;
import com.smartwebx.ha.dal.assign.bean.HaDirectory;

public class AjaxDeleteOrganize {
	@Autowired
	private HaReportManager haReportManager;
	@Autowired
	private HaDirectoryManager haDirectoryManager;
	@Autowired
	private HaReportAreaManager haReportAreaManager;
	@Autowired
	private HaReportUserManager haReportUserManager;
	public void execute(@Param("organizeIds") String organizeIds) throws IOException{
		ObjectMapper mapper = new ObjectMapper();
		mapper.configure(
				DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
		System.out.println(organizeIds);
		HaDirectory h = haDirectoryManager.select(Integer.parseInt(organizeIds.substring(1, organizeIds.length())));
		int reportId = h.getReportId();
		//haReportManager.delete(reportId);
		haDirectoryManager.delete(Integer.parseInt(organizeIds.substring(1, organizeIds.length())));
		haReportAreaManager.delete(reportId);
		haReportUserManager.delete(reportId);
		haReportManager.delete(reportId);
	}

}